import type { ApiResponse, BaseRecordSearchWrapper, BaseRecordVo, TableQuery } from '@/types/basetypes';
import type { ExaminaionBankForm } from '@/types/examinaion/types';
import type { TableConfigrationType } from '@/types/table-configtypes';
import type { QueryWrapper, UpdateWrapper } from '@/types/wrappertypes';
import request from '@/utils/request'

// 查询题库列表信息
export function _getExaminaionBankList(params: object) {
  return request({
    url: '/examinaion-bank/query-all',
    method: 'GET',
    params: params,
  });
}

// 查询题库信息
export const _getExaminaionBankInfo = async (params: { id: string }): Promise<ApiResponse<ExaminaionBankForm>> => {
  const { id } = params;
  return request({
    url: `/examinaion-bank/query-details/${id}`,
    method: 'GET',
  });
}

// 保存题库信息
export const _saveExaminaionBankInfo = async (params: object): Promise<ApiResponse<void>> => {
  return request({
    url: '/examinaion-bank/insert',
    method: 'POST',
    data: params,
  });
}

// 更新题库信息
export const _modifyExaminaionBankInfo = async (params: UpdateWrapper): Promise<ApiResponse<void>> => {
  return request({
    url: '/examinaion-bank/modify',
    method: 'POST',
    data: params,
  });
}

// 删除题库信息
export const _delExaminaionBankInfoByIds = async (ids: string): Promise<ApiResponse<void>> => {
  return request({
    url: '/examinaion-bank/del-ids',
    method: 'POST',
    data: { ids: ids },
  });
}

// 查询题库操作记录
export const _getExaminaionBankRecordInfos = async (params: { id: string }): Promise<ApiResponse<BaseRecordVo[]>> => {
  const { id } = params;
  return request({
    url: `/examinaion-bank/query-details-record/${id}`,
    method: 'GET',
  });
}

// 新增备注
export const _saveExaminaionBankRecordRemarkInfos = async (params: { bizId: string, remark: string }): Promise<ApiResponse<void>> => {
  return request({
    url: '/examinaion-bank/insert-remark',
    method: 'POST',
    data: params,
  });
}

// 搜索操作记录
export const _searchExaminaionBankRecordRemarkInfos = async (params: BaseRecordSearchWrapper): Promise<ApiResponse<BaseRecordVo[]>> => {
  return request({
    url: '/examinaion-bank/query-details-record-wrapper',
    method: 'POST',
    data: params,
  });
}

// 查询题库表格配置数据
export const _getExaminaionBankTableConfigeration = async (): Promise<ApiResponse<TableConfigrationType>> => {
  return request({
    url: `/examinaion-bank/query-table-config`,
    method: 'GET',
  });
}

// 查询题库表格列表数据
export const _getExaminaionBankTableList = async (params: QueryWrapper): Promise<ApiResponse<TableQuery<ExaminaionBankForm>>> => {
  return request({
    url: `/examinaion-bank/query-table-list`,
    method: 'POST',
    data: params
  });
}



//生成试卷
export const _createExamPaper = async (params: { examinaionBanckId: string; count: number; }[]): Promise<ApiResponse<boolean>> => {
  return request({
    url: `/examinaion-bank/create-paper`,
    method: 'POST',
    data: params
  });
}